//
//  RBHomeListHeaderView.m
//  zhongzhenglu
//
//  Created by XL on 2022/5/26.
//

#import "RBHomeListHeaderView.h"
#import "RBDefine.h"
#import <YYCategories.h>
#import <Masonry.h>

@interface RBHomeListHeaderView ()

@property(nonatomic, strong)UILabel *titleL;
@property(nonatomic, strong)UIImageView *moreImgView;

@end

@implementation RBHomeListHeaderView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        self.moreImgView.hidden = NO;
    }
    return self;
}

#pragma mark - Event

- (void)moreImgViewTapped
{
    if (self.moreBlock)
    {
        self.moreBlock();
    }
}

#pragma mark - Setter

- (void)setTitle:(NSString *)title
{
    _title = title;
    self.titleL.text = title;
}

#pragma mark - Getter

- (UILabel *)titleL
{
    if (!_titleL)
    {
        self.titleL = ({
            UILabel *view = UILabel.new;
            view.font = [UIFont systemFontOfSize:Zoom(18) weight:UIFontWeightBold];
            view.textColor = [UIColor colorWithHexString:@"333333"];
            [self addSubview:view];
            [view mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(Zoom(17));
                make.centerY.mas_equalTo(0);
            }];
            view;
        });
    }
    return _titleL;
}

- (UIImageView *)moreImgView
{
    if (!_moreImgView)
    {
        self.moreImgView = ({
            UIImageView *view = UIImageView.new;
            view.image = [UIImage imageNamed:@"homeListMore"];
            view.contentMode = UIViewContentModeScaleAspectFit;
            [self addSubview:view];
            [view mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.bottom.mas_equalTo(0);
                make.right.mas_equalTo(-Zoom(20));
                make.width.mas_equalTo(Zoom(27));
            }];
            view;
        });
    }
    return _moreImgView;
}

@end
